package com.leiduoduo.oms.controller;

import com.leiduoduo.oms.annotation.PassToken;
import com.leiduoduo.oms.pojo.Restaurant;
import com.leiduoduo.oms.service.RestaurantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
public class RestaurantController {
    @Autowired
    RestaurantService restaurantService;

    @PostMapping("/addRestaurant")
    @PassToken
    public boolean addRestaurant(Restaurant restaurant){
        return restaurantService.addRestaurant(restaurant);
    }
    @PostMapping("/delRestaurant")
    @PassToken
    public boolean delRestaurant(Restaurant restaurant){
        return restaurantService.delRestaurant(restaurant);
    }
    @GetMapping("/upRestaurant")
    @PassToken
    public boolean upRestaurant(Restaurant restaurant){
        return restaurantService.upRestaurant(restaurant);
    }
    @GetMapping("/getRestaurantById/{id}")
    @PassToken
    public Restaurant getRestaurantById(@PathVariable("id") int id){
        return restaurantService.getRestaurantById(id);
    }
    @GetMapping("/getRestaurantList")
    @PassToken
    public List<Restaurant> getRestaurantList(){
        return restaurantService.getRestaurantList();
    }
}
